import Axios from 'axios';
import baseURL, { URLs } from './URLS';

const instance = Axios.create({
  baseURL,
  params: {},
});

const Search = (value, page, size) => instance.get(
  URLs.search,
  { params: { keywords: value, limit: size, offset: page} },
);
// 获取歌曲详情
const getSongInfo = (ids) => instance.get(
  URLs.songDetail,
  { params: { ids } },
);
const getDragonBall = () => instance.get(
  URLs.dragonBall
);
const getBanner = () => instance.get(
  URLs.banner
);
const getPersonalized = (value) => instance.get(
  URLs.personalized,
  { params: { limit: value } },
);
const getDjHotList = (value) => instance.get(
  URLs.djHot,
  { params: { limit: value } },
);
const getSongUrl = (ids) => instance.get(
  URLs.songUrl,
  { params: { id: ids } },
);
const getCaptcha = (phone) => instance.get(
  URLs.captchaSent,
  { params: { phone } },
);
const phoneLogin = (obj) => instance.get(
  URLs.phoneLogin,
  { params: { phone: obj.phone,captcha: obj.captcha } },
);
const captchaVerify = (obj) => instance.get(
  URLs.captchaVerify,
  { params: { phone: obj.phone,captcha: obj.captcha } },
);
const searchKeywords= (keywords) => instance.get(
  URLs.searchKeywords,
  { params: { keywords } },
);

export default {
  Search,
  getSongInfo,
  getDragonBall,
  getBanner,
  getPersonalized,
  getDjHotList,
  getSongUrl,
  getCaptcha,
  phoneLogin,
  captchaVerify,
};
